#include <stdio.h>
#include "ofc/DSystemLogger.h"
#include "ofc/DLog.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DSYSTEMLOGGER
  DSystemLogger *logger = [DSystemLogger alloc];
  int            i;

  [logger init :"example" :NO];        // Init the logger with application "example" and logging to stderr

  dlogger(logger);                     // Give tot the base logger the system logger as destination

  dlog(DLOG_ALERT, "Alert!!");         // Log an alert

  for (i = 0; i < 10; i++)             // Add a repeated error message
  {
    dlog(DLOG_ERROR, "Errors");
  }

  dlogmask(DLOG_NOTICE|DLOG_DEBUG);    // Mask some log levels
    
  dlog(DLOG_WARNING, "Warning..Masked"); // Masked warning
  dlog(DLOG_DEBUG,   "Debug:%d",7);    // Debug message
  dlog(DLOG_NOTICE,  "Notice");        // Notice message

  dlogger(nil);                        // Stop logging via the system logger

  [logger free];                       // Cleanup

  printf("Events succesfully sent to the system logger.\n");
#else
  printf("DSystemLogger is not present in the library.\n");
#endif

  return 0;
}

